<?php
namespace Weixin\Controller;
use Think\Controller;
class CardController extends BaseController{
	//初始化
	public function inquery(){
		$eAccount = M('User')->where("user_id='%d'",session('uid'))->getField('eAccount');
		if($eAccount){
			$data = array('SubAcctNo'=>$eAccount);
			$data = \Util\Rsa::get_encrypt_data($data);
			$url = 'http://bankapi.chedai0.com:8080/demo_1/SHBank/checkEAccount';
			$result = \Util\Curl::http_post($url,$data);
			$result = json_decode($result,true);
			if($result['code'] == '200'){
				$ret_data = $result['info'];
				$ret_data =  \Util\Rsa::get_decrypt_data($ret_data);
				$this->assign('ret_data',$ret_data);
				$this->display();
			}
		}
	}

	public function encrypt_data(){
		$json = htmlspecialchars_decode(urldecode(I('post.json')));
		$data = json_decode($json,true);
		$data = \Util\Rsa::get_encrypt_data($data);
		echo json_encode($data);
	}

	public function inquery_eaccount(){
		$url = 'http://bankapi.chedai0.com:8080/demo_1/SHBank/checkEAccount';
		$data = array('SubAcctNo'=>I('eAccount'));
		$data = \Util\Rsa::get_encrypt_data($data);
		$result = \Util\Curl::http_post($url,$data);
		$result = json_decode($result,true);
		if($result['code'] == '200'){
			$ret_data = $result['info'];
			$ret_data =  \Util\Rsa::get_decrypt_data($ret_data);
			echo json_encode($ret_data);
		}
	}
}